package com.gis507.test.AISTest4;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * 1、继承Partitioner
 * 2、指定输入输出类型
 * 3、重写getPartition
 */
public class AISDataPartition extends Partitioner<Text,AISDataBean> {

    @Override
    public int getPartition(Text text, AISDataBean aisDataBean, int numPartitions) {

        //判断设置不同的分区
        if ("油轮".equals(aisDataBean.getDraught())){
            return 0;
        }else if ("货船".equals(aisDataBean.getDraught())){
            return 1;
        }else if ("客船".equals(aisDataBean.getDraught())){
            return 2;
        }else if ("拖轮".equals(aisDataBean.getDraught())){
            return 3;
        }else {
            return 4;
        }
    }
}
